{% extends "./tmplinfo.html" %}

{% block head %}

<title>{{ postinfo.title }} </title>

<meta name="keywords" content="{{ postinfo.extinfo.get('keywords','') }},{{ postinfo.title }}">

<meta name="description" content="{% module generate_abstract(postinfo.cnt_html) %}">
<style>
    .div_border {
        border-bottom: 1px dashed #ddd;
        padding: 5px 0;
    }
</style>

{% end %}

{% block typebody %}

<script>

    var post_uid = "{{ postinfo.uid }}";

    var login = {{ kwd['login'] }};

</script>

<div class="container mainbh mtop">

    <div class="row">

        <div class="col-sm-9">

            <ol class="breadcrumb">

                <li><a href="/" title="{{ _('Home') }}"> {{ _('Home') }}</a></li>

                <li><a href="/filter/{{ pcatinfo.uid }}" title="{{ pcatinfo.name }}">{{ pcatinfo.name }}</a></li>

                <li><a href="/filter/{{ catinfo.uid }}" title="{{ catinfo.name }}">{{ catinfo.name }}</a></li>

                <li>{{ _('Text') }}</li>

            </ol>

            <div class="panel panel-black">

                <div class="panel-heading ">
                    <h3 class="listinfo_title">
                        {{ postinfo.title }}
                    </h3>
                </div>

                <div class="panel-body">

                    <div class="row">
                        {% if postinfo.logo != '' %}
                        <div class="col-sm-12 bor_bottom ">
                            <div class="col-sm-6 ">
                                <img src="{{ postinfo.logo }}" alt="{{ postinfo.logo }}" class="img-thumbnail">
                            </div>
                            <div class="col-sm-6">

                                {% module collect(userinfo.uid, postinfo.uid,en=True) %}

                                {% module widget_editor(kwd['router'], postinfo.uid, userinfo,kind = postinfo.kind) %}

                                <p>
                                    <strong>{{ _('Release time') }}：</strong>{{ datetime.datetime.fromtimestamp(postinfo.time_create).strftime('%Y-%m-%d') }}
                                </p>
                                <p><strong>{{ _('Browsing times') }}：</strong> {% raw postinfo.view_count %}</p>

                                <p><strong>Tag:</strong><span class="post_label">
                        {% set iii = 1 %}
                                    {% if iii > 5 %}
                                    {% set iii = 1 %}
                                    {% end %}
                    {% for x in tag_info %}
                    <a href="/label/{{ postinfo.kind }}/{{ x.tag_uid }}" class="tag{{ iii }}"
                       title="{{ x.tag_name }}">{{ x.tag_name }}</a>
                    {% set iii = iii + 1 %}
                    {% end %} </span></p>


                                {% if userinfo %}
                                {% if 'tag__file_download' in postinfo.extinfo and postinfo.extinfo['tag__file_download'] != '' %}
                                <p style="float:right;">
                                    <a class="btn btn-danger btn-sm" title="Download Dataset"
                                       href="{{ postinfo.extinfo['tag__file_download'] if 'tag__file_download' in postinfo.extinfo else '' }}"
                                       target="_blank">
                                        <span class="glyphicon glyphicon-download-alt"> </span>
                                        {{ _('Download Dataset') }}</a></p>

                                {% end %}
                                {% end %}

                                {% if 'ext_pdf' in postinfo.extinfo and postinfo.extinfo['ext_pdf'] != '' %}
                                <p><a class="btn btn-info btn-sm" title="View Document"
                                      href="{{ postinfo.extinfo['ext_pdf'] if 'ext_pdf' in postinfo.extinfo else '' }}"
                                      target="_blank">
                                    <span class="glyphicon glyphicon-new-window"> </span>
                                    {{ _('View Document') }}</a></p>

                                {% end %}

                            </div>

                        </div>

                        {% else %}
                        <div class="col-sm-12 bor_bottom">


                            {% if userinfo %}
                            {% module collect(userinfo.uid, postinfo.uid,en=True) %}

                            {% end %}
                            {% module widget_editor(kwd['router'] , postinfo.uid, userinfo,kind = postinfo.kind) %}


                            <strong>{{ _('Release time') }}：</strong>
                            <span>{{ datetime.datetime.fromtimestamp(postinfo.time_create).strftime('%Y-%m-%d') }}&nbsp;</span>
                            &nbsp;&nbsp;&nbsp;&nbsp;<strong>{{ _('Browsing times') }}：</strong>
                            {% raw postinfo.view_count %}&nbsp;&nbsp;&nbsp;&nbsp;

                            <br>
                            <br>
                            <p><strong>{{ _('Tag') }}:</strong><span class="post_label">
                              {% set iii = 1 %}
                                 {% if iii > 5 %}
                                    {% set iii = 1 %}
                                    {% end %}
                    {% for x in tag_info %}
                    <a href="/label/{{ postinfo.kind }}/{{ x.tag_uid }}" class="tag{{ iii }}"
                       title="{{ x.tag_name }}">{{ x.tag_name }}</a>
                    {% set iii = iii + 1 %}
                    {% end %}
                </span>&nbsp;&nbsp;&nbsp;&nbsp;

                            </p>
                            {% if userinfo %}
                            {% if 'tag__file_download' in postinfo.extinfo and postinfo.extinfo['tag__file_download'] != '' %}
                            <p style="float:right;">
                                <a class="btn btn-danger btn-sm" title="Download Dataset"
                                   href="{{ postinfo.extinfo['tag__file_download'] if 'tag__file_download' in postinfo.extinfo else '' }}"
                                   target="_blank">
                                    <span class="glyphicon glyphicon-download-alt"> </span>
                                    {{ _('Download Dataset') }}</a></p>

                            {% end %}
                            {% end %}

                            {% if 'ext_pdf' in postinfo.extinfo and postinfo.extinfo['ext_pdf'] != '' %}
                            <p><a class="btn btn-info btn-sm" title="View Document"
                                  href="{{ postinfo.extinfo['ext_pdf'] if 'ext_pdf' in postinfo.extinfo else '' }}"
                                  target="_blank">
                                <span class="glyphicon glyphicon-new-window"> </span>
                                {{ _('View Document') }}</a></p>

                            {% end %}

                        </div>

                        {% end %}


                    </div>
                    <div id="wiki_cnt" class="col-sm-12 listinfo_content ">
                        {% raw unescape(postinfo.cnt_html) %}
                    </div>
                    <div class="col-sm-12 ">
                        {% block extrainfo %} {% end %}


                        <!--<div class='bor_bottom'> </div>-->


                    </div>


                    <div class="col-sm-12">

                        <span id="showCnt"></span>

                    </div>

                    {% if postinfo.extinfo.get('ext_map_layers') %}
                    <script>
                        $(document).ready(function () {
                            var post_uid = "{{postinfo.uid}}";
                            var login = {{kwd['login']}};
                            var map_url = "{{postinfo.extinfo.get('ext_map_url','https://tile.osgeo.cn/service?')}}";
                            var map_layers = "{{postinfo.extinfo.get('ext_map_layers','q_cp_imagery_imagery')}}";


                            var currentX, currentY, currentZoom, geojsonid, map_uid, mapson, vlat, vlon, vmarker,
                                vzoom_current, vzoom_max,
                                vzoom_min;
                            mapson = $("#map_vkz").data("map")

                            vlon = mapson.x
                            vlat = mapson.y
                            vzoom_current = mapson.v
                            vzoom_max = mapson.m
                            vzoom_min = mapson.n


                            function test_fun2() {


                                var info_map_center = map.getCenter();
                                currentZoom = map.getZoom();

                            }

                            function test_fun3(e) {


                                vmarker = e.latlng;
                                currentZoom = map.getZoom();

                            }

                            function onMapClick(e) {
                                popup.setLatLng(e.latlng)
                                    .setContent('Location:' + e.latlng.toString())
                                    .openOn(map);
                            }

                            //创建地图
                            var map = L.map('map_vkz', {
                                center: [vlat, vlon],
                                crs: L.CRS.EPSG3857,
                                zoom: vzoom_current,
                                maxZoom: vzoom_max,
                                minZoom: vzoom_min,
                                editable: true,

                                // 去除放大缩小控件
                                // https://stackoverflow.com/questions/16537326/leafletjs-how-to-remove-the-zoom-control
                                zoomControl: false,
                                layerControl: false,
                                attributionControl: false,
                                // Attribution: false,
                            });
                            var popup = L.popup();
                            map.on('click', onMapClick);
                            map.on('move', test_fun2);
                            map.on('mousemove', test_fun3);


                            // 天地图地图及标示  osm，osm1.
                            var osm = L.tileLayer('http://t4.tianditu.gov.cn/DataServer?T=vec_w&X={x}&Y={y}&L={z}&tk=57f1b8146ef867f14189f3f4bb1adc1c', {
                                title: '天地图网格图',
                                maxZoom: 18,
                                id: 'mapbox.streets'
                            });


                            var osm1 = L.tileLayer.chinaProvider("TianDiTu.Normal.Map", {
                                maxZoom: 18,
                                minZoom: 1
                            })
                            var osm2 = L.tileLayer("http://t{s}.tianditu.gov.cn/DataServer?T=eva_w&x={x}&y={y}&l={z}&tk=57f1b8146ef867f14189f3f4bb1adc1c", {
                                subdomains: ['0', '1', '2', '3', '4', '5', '6', '7']
                            })
                            var the_basemap = L.layerGroup([osm1, osm2]);

                            the_basemap.addTo(map);


                            var geomor = L.tileLayer.wms(map_url, {
                                layers: map_layers,
                                format: 'image/png',
                                transparent: true,
                                backgroundColor: '#0f0f0f'
                            }).addTo(map);

                            L.control.scale({
                                position: 'bottomright',
                                maxWidth: '100',
                                imperial: false
                            }).addTo(map);


                        })
                    </script>
                    <h3>{{ _('Data Visualization on Map') }}</h3>
                    <div class="row">
                        <div class="col-sm-8">
                            <div id="map_vkz" style=" width: 100%; height: 350px; z-index: 1; " tabindex="0"
                                 data-map='{"i": "{{ postinfo.uid[1:] }}",
        "x":{{ postinfo.extinfo.get('ext_lon','69') }},
        "y": {{ postinfo.extinfo.get('ext_lat','32') }},
        "v": {{ postinfo.extinfo.get('ext_zoom_current','4') }},
        "m": {{ postinfo.extinfo.get('ext_zoom_max','7') }},
        "n" : {{ postinfo.extinfo.get('ext_zoom_min','1') }},

        "login": {{ kwd['login'] }}
        }'></div>
                        </div>
                        <div class="col-sm-4">

                            <div id="iga_view_rec_box">

                                <div class="row">
                                    <div class="col-sm-6">
                        <span class="des">
                             <b>{{ _('Central point longitude ') }} </b>
                         </span>
                                    </div>
                                    <div class="col-sm-6">
                                        {{ postinfo.extinfo.get('ext_lon','69') }}
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-6">
                        <span class="des">
                            <b>{{ _('Central point latitude ') }} </b>
                        </span>
                                    </div>
                                    <div class="col-sm-6">
                                        {{ postinfo.extinfo.get('ext_lat','32') }}
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-6">
                        <span class="des">
                            <b>{{ _('Max zoom level ') }} </b>
                        </span>
                                    </div>
                                    <div class="col-sm-6">
                                        {{ postinfo.extinfo.get('ext_zoom_max','7') }}
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-6">
                        <span class="des">
                            <b>{{ _('Min zoom level ') }} </b>
                        </span>
                                    </div>
                                    <div class="col-sm-6">
                                        {{ postinfo.extinfo.get('ext_zoom_min','1') }}
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-6">
                        <span class="des">
                             <b>{{ _('Current zoom level ') }} </b>
                        </span>
                                    </div>
                                    <div class="col-sm-6">
                                        {{ postinfo.extinfo.get('ext_zoom_current','4') }}
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <Br>
                                        {% if postinfo.extinfo.get('ext_xml') %}
                                        <a class="btn btn-primary btn-sm" target="_blank"
                                           onclick="down_xml('{{ postinfo.uid }}');">
                                            <span class="glyphicon glyphicon-share"></span>
                                            {{ _('View Metadata') }} ({{ _('in XML format') }})
                                        </a>
                                        {% end %}
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                    {% end %}
                    <br>
                </div>

                <div class="panel-footer">

                    <div class="row">

                        <div class="col-md-12"
                             style="overflow: hidden; text-overflow:ellipsis; white-space: nowrap; display: block;">

                            {{ _('Article link') }}： <a href="/{{ kwd['router'] }}/{{ postinfo.uid }}"
                                                        style="color: #003366"
                                                        title="{{ postinfo.title }}">{{ postinfo.title }}</a>

                        </div>


                    </div>

                </div>

            </div>

        </div>

        <div class="col-sm-3">

            <div class="panel panel-black">
                <div class="panel-heading">
                    <b> {{ _('Information evaluation') }}</b>
                </div>
                <div class="panel-body" style="font-size: x-small">
                    {% module star_rating(postinfo, userinfo) %}
                </div>
            </div>
            <div class="panel panel-black">
                <div class="panel-heading">
                    {{ _('Most attention') }}
                </div>
                <ul class="list-group" id="mostall">
                    {% module post_most_view(5, with_date = False, with_catalog= False,kind=postinfo.kind) %}
                </ul>
            </div>
            <div class="panel panel-black">
                <div class="panel-heading">
                    {{ _('Recent articles') }}
                </div>
                <ul class="list-group">
                    {% module post_recent(5, with_date = False, with_catalog= False,kind=postinfo.kind) %}
                </ul>
            </div>

            <div class="panel panel-black">
                <div class="panel-heading"> {% for taginfo in cat_enum %}
                    {% if taginfo.uid.endswith('00') %}
                    {{ taginfo.name }}
                    {% end %}
                    {% end %}
                </div>
                <ul class="list-group">
                    {% for taginfo in cat_enum %}
                    {% if not taginfo.uid.endswith('00') %}
                    <li class="list-group-item"><a href="/filter/{{ taginfo.uid }}"
                                                   title="{{ taginfo.name }}">{{ taginfo.name }}</a></li>
                    {% end %}
                    {% end %}
                </ul>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    function download_excel() {

        $.ajax({
            url: "/{{ kwd['router'] }}/download_excel/{{ postinfo.uid }}",
            type: "get",
            cache: false,
            data: '',
            processData: false,
            contentType: false,

            success: function (data) {
                var msg_json = $.parseJSON(data);
                var file_src = msg_json.file_src;
                window.location.href = file_src


            },
            error: function () {
            }

        });


    }
</script>
<script>function down_xml(uid) {

    $.ajax({
        url: "/{{ kwd['router'] }}/_downxml/" + uid,
        type: "get",
        data: '',
        timeout: 1e3,
        processData: false,
        contentType: false,
        error: function () {
//                    alert("Reload")
        },
        success: function (result) {
            var msg_json = $.parseJSON(result);
            if (msg_json.down_code == 1) {
                window.open(msg_json.down_url)
            }
        }
    })

}</script>
{% end %}
